﻿using System;
using System.Windows;
using System.Windows.Controls;
using SomethingSpacial.ViewModel;
using SomethingSpacialClassLib.Web;


namespace SomethingSpacial.Views.Admin
{
    public partial class EventList : Page
    {

        public EventsViewModel ViewModel
        {
            get
            {
                return (EventsViewModel)DataContext;
            }
        }
        public EventList()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(EventList_Loaded);
        }

        #region "Page Events"

        void EventList_Loaded(object sender, RoutedEventArgs e)
        {
            
        }


        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            editDataForm.CommitEdit();
        }

        private void buttonAddNew_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.CreateNewEvent();
        }

        private void buttonSaveNew_Click(object sender, RoutedEventArgs e)
        {
            Dispatcher.BeginInvoke(ViewModel.CommitChanges);
        }

        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.DeleteEvent(ViewModel.CurrentEvent);
        }

        #endregion











    }
}
